<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="viewport" content="width=device-width, initial-scale=1" />
		<script th:src="@{/static/js/jquery.min.js}" type="text/javascript" charset="utf-8"></script>
		<script th:src="@{/static/js/afquery.js}" type="text/javascript" charset="utf-8"></script>
		<script th:src="@{/static/layui/layui.all.js}" type="text/javascript" charset="utf-8"></script>
		<link rel="stylesheet" type="text/css" th:href="@{/static/layui/css/layui.css}" />
		<link rel="stylesheet" type="text/css" th:href="@{/static/css/Common.css}" />
	</head>
	<body>
		<div class="layui-container">
			<div class="layui-row" style="margin-top: 100px;">
				
			   <div class="layui-col-xs12 layui-col-md6 layui-col-md-offset3" style="background-color: whitesmoke;padding-top: 20px;">
			     <div class="grid-demo grid-demo-bg1">
					 <div class="layui-form-item">
					     <label class="layui-form-label">用户名</label>
					     <div class="layui-input-block">
					       <input type="text" name="title" lay-verify="title" autocomplete="off" placeholder="请输入用户名" class="layui-input" style="width: 80%;">
					     </div>
					 </div>
					 <div class="layui-form-item">
					     <label class="layui-form-label">密码</label>
					     <div class="layui-input-block">
					       <input type="password" name="title" lay-verify="title" autocomplete="off" placeholder="请输入密码" class="layui-input" style="width: 80%;">
					     </div>
					 </div>
					 <div class="layui-form-item">
					   <div class="layui-col-xs3 layui-col-md3 layui-col-md-offset3 layui-col-xs-offset3">
						  <button type="button" class="layui-btn layui-btn-lg layui-btn-primary layui-btn-radius" onclick="M.login()">登录</button>
					   </div>
					   <div class="layui-col-xs3 layui-col-md3 layui-col-md-offset1 layui-col-xs-offset1">
						  <button type="button" class="layui-btn layui-btn-lg layui-btn-primary layui-btn-radius">取消</button>
					   </div>

					 </div>
				 </div>
			   </div>
			 </div>

		</div>
		
	</body>
	
	<script th:inline="javascript">
		var M = {};
		
		M.login = function(){
			var req = {};
			req.userID = $(".grid-demo input:eq(0)").val().trim();
			req.password = $(".grid-demo input:eq(1)").val().trim();
			
			if(req.userID.length == 6 && req.password >= 6 || req.password <=15){
				req.userID = Number(req.userID);
				Af.rest([[@{Teacherlogin.do}]],req,function(data){
					window.location = "index";
				});
			}else if(req.userID.length == 9 && req.password >= 6 || req.password <=15){
				req.userID = Number(req.userID);
				Af.rest([[@{Studentlogin.do}]],req,function(data){
					window.location = "index";
				});
			}else{
				alert("不合法的输入格式");
			}
		}
	</script>
</html>
